from typing import *
from sortedcontainers import SortedList
from cmath import inf


class Solution:
    def minimumDistance(self, points: List[List[int]]) -> int:
        sd1 = SortedList()
        sd2 = SortedList()
        for a, b in points:
            sd1.add(a - b)
            sd2.add(a + b)
        ans = inf
        for a, b in points:
            if (
                a - b == sd1[-1]
                or a - b == sd1[0]
                or a + b == sd2[-1]
                or a + b == sd2[0]
            ):
                sd1.remove(a - b)
                sd2.remove(a + b)
                ans = min(ans, max(sd1[-1] - sd1[0], sd2[-1] - sd2[0]))
                sd1.add(a - b)
                sd2.add(a + b)
        return ans
